package br.com.lh.urabuilder.domain.xml
{
	import flash.utils.describeType;
	
	
	public class Option 
	{
		public var pattern:String;
		public var nextId:int;
		
		public function Option(xml:XML = null){
			if (xml!=null){
				buildFromXml(xml);
			}
		}
		
		public function toXML():XML{
			var newXmlRow:XML= <Option></Option>
			var x:XML = describeType(this);
			var xl:XMLList = x..variable;
			for each(var n:XML in xl){
			var nodeName:String =n.@name.toString();
			if (this[nodeName]!=null){
				newXmlRow['@' + nodeName] = this[nodeName];
				}
			}
			return newXmlRow;
		}
		
		
		public function buildFromXml(element:XML):void{
			var x:XML = describeType(this);
			var variables:XMLList = x..variable;
			for each(var n:XML in variables){
				var nodeName:String =n.@name.toString();
				var xmlValue:String = element['@' + nodeName];
				this[nodeName]= xmlValue;
				}
		}

	}
}